﻿using MediatR;
using MediatR.RequestHandlerFactory;
using Microsoft.Extensions.DependencyInjection;

namespace SW.DDD.Application.Query
{
    public static class DependencyInjectionExtensions
    {
        public static IServiceCollection AddQueryHandler(this IServiceCollection services)
        {
            services.AddTransient(typeof(FindHandler<,,>));
            services.AddTransient<IRequestHandlerFactory, FindHandlerFactory>();
            services.AddTransient(typeof(QueryHandler<,,>));
            services.AddTransient<IRequestHandlerFactory, QueryHandlerFactory>();
            services.AddTransient(typeof(SubsQueryHandler<,,,>));
            services.AddTransient<IRequestHandlerFactory, SubsQueryHandlerFactory>();
            services.AddTransient(typeof(IRequestHandler<,>), typeof(RequestHandlerProvider<,>));
            return services;
        }
    }
}
